var header = {};
header.setCookie = function (key,value){
	document.cookie = key+"="+value
}
header.getCookie = function (key){
	var cArray = document.cookie.split("; ");
	var c = null;
	var result = "";
	for(var i = 0 ; i < cArray.length ;i++){
		c = cArray[i];
		if(c.indexOf(key) > -1){
			result = c.split("=")[1];
			break;
		}
	}
	return result;
}
$(function (){
	var h = location.href;
	if(h.indexOf("gujia") > -1){
		$("#gujia").addClass("checked")
	}else if(h.indexOf("deal") > -1){
		$("#his").addClass("checked")
	}else if(h.indexOf("aboutMe") > -1){
		$("#me").addClass("checked")
	}else{
		$("#wx").addClass("checked")
	}
 	$("#nowCity").click(function() {
		if($(".city-all").is(":hidden")){
			$(".city-all").show();
		}else{
			$(".city-all").hide();
		}
	})
	//2018-09-27
	$(".city-list").children().click(function (){
		$("#nowCity").html($(this).text());
		$("#nowCity").attr("citycode",$(this).attr("citycode"));
		$(".city-all").hide();
		document.cookie = 'cc='+encodeURI($(this).text())+"-"+$(this).attr("citycode");
		window.location.href = window.location.href;
	})
	var cc = header.getCookie("cc");
	if(cc != ''){
		var cList = cc.split("-");
		$("#nowCity").text(decodeURI(cList[0]));
		$("#nowCity").attr("citycode",cList[1]);
	}
})